<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2017/5/22
  Time: 9:03
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <jsp:include page="../../head.jsp"/>
    <title>基础数据维护</title>
    <script type="text/javascript">
        var formSetting = {
            title: "查询信息",
            module: 'query',
            columns: [
                {
                    index: "code",
                    name: "code",
                    label: "代码"
                }, {
                    index: "DICTIONARY_NAME",
                    name: "DICTIONARY_NAME",
                    label: "字典名称"
                }, {
                    index: "STATUS",
                    name: "STATUS",
                    label: "状态",
                    type: "dropdown",
                    data: [["启用", "0"], ["注销", "1"]],
                    op: "eq",
                    minLength: 0
                }
            ],
            buttons: {
                custom: [
                    {
                        id: "addBtn",
                        value: "添加",
                        click: function () {
                            location.href = "detailPage?groupCode=${groupCode}&groupId=${groupId}";
                        }
                    }, {
                        id: "editBtn",
                        value: "修改",
                        click: function () {
                            var selectedRowId = $("#dictionaryDataGrid")
                                .getGridParam("selrow");
                            if (selectedRowId) {
                                var selectedRow = $("#dictionaryDataGrid")
                                    .getRowData(selectedRowId);
                                location.href =
                                    "detailPage?groupCode=${groupCode}&groupId=${groupId}&id="
                                    + selectedRow.ID;
                            } else {
                                alert("请选择需要修改的记录!")
                            }
                        }
                    }, {
                        id: "delBtn",
                        value: "删除",
                        click: function () {
                            var selectedRowId = $("#dictionaryDataGrid")
                                .getGridParam("selrow");
                            if (selectedRowId) {
                                var selectedRow = $("#dictionaryDataGrid")
                                    .getRowData(selectedRowId);
                                if (confirm("确认要删除吗？")) {
                                    $.ajax({
                                               url: "./deleteDictionary",
                                               dataType: "json",
                                               data: "id=" + selectedRow.ID,
                                               success: function (data) {
                                                   alert(data.msg);
                                                   window.location.reload();
                                               }
                                           });
                                }
                            } else {
                                alert("请选择需要删除的记录!")
                            }
                        }
                    }]
            },
            grid: {
                id: "dictionaryDataGrid",
                title: "查询结果",
                url: "findPageList?groupCode=${groupCode}&groupId=${groupId}",
                multiselect: false,
                colModel: [{
                    index: "ID",
                    name: "ID",
                    hidden: true
                }, {
                    index: "GROUP_ID",
                    name: "GROUP_ID",
                    hidden: true
                }, {
                    index: "DICTIONARY_CODE",
                    name: "DICTIONARY_CODE",
                    label: "字典代码"
                }, {
                    index: "DICTIONARY_NAME",
                    name: "DICTIONARY_NAME",
                    label: "字典名称"
                }, {
                    index: "DESCRIPT",
                    name: "DESCRIPT",
                    label: "描述"
                }, {
                    index: "STATUS",
                    name: "STATUS",
                    label: "状态",
                    formatter: function (cellvalue, options, rowObject) {
                        if (cellvalue == "0") {
                            return "启用";
                        } else if (cellvalue == "1") {
                            return "注销";
                        } else {
                            return "";
                        }
                    }
                }, {
                    index: "CREATOR",
                    name: "CREATOR",
                    label: "创建人"
                }, {
                    index: "CREATE_TIME",
                    name: "CREATE_TIME",
                    label: "创建时间"
                }, {
                    index: "MODIFIER",
                    name: "MODIFIER",
                    label: "最后一次修改人"
                }, {
                    index: "MODIFY_TIME",
                    name: "MODIFY_TIME",
                    label: "最后一次修改时间"
                }],
                sortname: "DICTIONARY_CODE",
                sortorder: "asc"
            }
        };
        $(document).ready(function () {
            $("#dictionaryDataTable").mrdForm(formSetting);
            $("backBtn").hide();
        });
    </script>
</head>
<body>
<div id="dictionaryDataTable"></div>
</body>
</html>
